function Vue(config={}){
    const {el,data={},method={}}=config;
    this.$el=el;
    this.$data=data;
    if(typeof el==="string"){
        this.el=document.querySelector(el);
    }
    //对数据侦听
    this.observe();
    //解析模版
    this.compile();
}

Object.assign(Vue.prototype,{
    observe(){
        for(let key in this.$data){
            Object.defineProperty(this,key,{
                get(){
                    return this.$data[key];
                },
                set(v){
                    this.$data[key]=v;
                }
            })
        }
    },
    //解析模版
    compile(){
        for(let i=0;i<this.$el.children.length;i++){
            //获取节点
            const node=this.$el.children[i];
            console.log(node);
            //v-model
            if(node.hasAttribute("v-model")){
                node.addEventListener("input",function(e){
                    console.log(e.target.value);
                })
                const value = node.getAttribute("v-model");
                node.value=this[value];
            }

            //v-html
            if(node.hasAttribute("v-html")){
               const value = node.getAttribute("v-html");
               node.innerHTML=this[value];
            }

            //v-text
            if(node.hasAttribute("v-text")){
                const value = node.getAttribute("v-text");
                node.innerText=this[value];
            }
        }
    }
})
export default Vue;